/*
 * Copyright (C) hushenglan
 */

#ifndef _MYSYS_THREAD_H_
#define _MYSYS_THREAD_H_

namespace mysys
{

#define MS_THREAD_RETURN void*

typedef pthread_t ms_thread_t;
typedef pthread_attr_t ms_thread_attr_t;
typedef void *(*thread_main_pt)(void*);

class CThread
{
public:

    /*
     * 构造函数
     */
    CThread(thread_main_pt routine, ms_thread_attr_t *tattr, void *arg);

    /*
     * 析构函数
     */
    virtual ~CThread();

    /*
     * 启动线程
     */
    int start();

private:

    ms_thread_t _tid;
    thread_main_pt _routine;
    void *_arg;
    ms_thread_attr_t *_tattr;
};

}

#endif
